from components.text import *
from components.rect import *
from components.common_road import *
from components.special_area import *
from components.express_way import *


class ComponentFactory:

    def __init__(self, text_size, text_color) -> None:
        self.text_size = text_size
        self.text_color = text_color

    def component(self, item_type, item_info):
        if item_type == 0:
            text = item_info.get('text')
            ele = TextAComponent(text, self.text_color, self.text_size)

        elif item_type == 1:
            name = item_info.get('name')
            ele = CommonRoadNationalComponent(name)

        elif item_type == 2:
            name = item_info.get('name')
            ele = CommonRoadProvincialComponent(name)

        elif item_type == 3:
            name = item_info.get('name')
            ele = CommonRoadTownshipComponent(name)

        elif item_type == 4:
            main_name = item_info.get('main_name')
            sub_name = item_info.get('sub_name') or ''
            ele = NationalExpressWayComponent(main_name, sub_name)

        elif item_type == 5:
            main_name = item_info.get('main_name')
            sub_name = item_info.get('sub_name') or ''
            prov = item_info.get('prov')
            ele = ProvincialExpressWayComponent(prov, main_name, sub_name)

        elif item_type == 6:
            name = item_info.get('name')
            ele = StreetComponent(name)

        elif item_type == 7:
            name = item_info.get('name')
            ele = TouristComponent(name)

        elif item_type == 8:
            text = item_info.get('text')
            en = item_info.get('en')
            ele = BilingualTextComponent(text, en, self.text_color, self.text_size)

        return ele